package com.challenge.smsdao.studentmanage.domain;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.challenge.smsbase.Domain.BaseEntity;
import com.challenge.smsdao.majormanage.domain.Major;

import javax.persistence.*;
import java.util.List;

/**
 * @author shaoyunfei
 *
 * inherit public entity
 */
@Entity
public class Grade extends BaseEntity<Long> {
    //create object
    @Column
    private String name;
    @JsonIgnoreProperties("grade")
    @OneToMany(mappedBy = "grade",cascade = {CascadeType.REMOVE,CascadeType.REFRESH},fetch = FetchType.LAZY)
    private List<Student> studentList;

    @JsonIgnoreProperties("grades")
    @ManyToOne(cascade = {CascadeType.REFRESH},fetch = FetchType.EAGER)
    @JoinColumn(name = "major_id")
    private Major major;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public List<Student> getStudentList() {
        return studentList;
    }

    public void setStudentList(List<Student> studentList) {
        this.studentList = studentList;
    }

    public Major getMajor() {
        return major;
    }

    public void setMajor(Major major) {
        this.major = major;
    }
}
